package com.jfsoft.demo1114.service.impl;

import com.jfsoft.demo1114.dao.mapper.StudysMapper;
import com.jfsoft.demo1114.dao.model.Studys;
import com.jfsoft.demo1114.service.IPageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service("pageService")
public class PageServiceImpl implements IPageService {

    @Autowired
    private StudysMapper studysMapper;

    @Override
    public Map<String, Object> query(String pid, String pname, Integer beginAge, Integer endAge, String ageUnit, String gender, String modality
            , String beginDate, String endDate, String studesc) throws Exception {
        Map<String, Object> map =new HashMap<>();
        Map<String, Object> params =new HashMap<>();
//        String ageStr=null;
//        if(beginAge !=null&&!StringUtils.isEmpty(ageUnit)){
//            if((beginAge /10)<1){
//                ageStr="00"+ beginAge +ageUnit;
//            }else if((beginAge /100)<1){
//                ageStr="0"+ beginAge +ageUnit;
//            }else{
//                ageStr= beginAge +ageUnit;
//            }
//        }

        params.put("pid",pid);
        params.put("pname",pname);
        params.put("beginAge",beginAge);
        params.put("endAge",endAge);
        params.put("ageUnit",ageUnit);
        params.put("gender",gender);
        params.put("modality",modality);
        params.put("beginDate",beginDate);
        params.put("endDate",endDate);
        params.put("studesc",studesc);
        List<Studys> list=studysMapper.query(params);
        map.put("data",list);
        map.put("status","success");
        return map;
    }
}
